//
//  UseLazyHGrid.swift
//  learn-ios
//
//  Created by Dong on 2022/4/5.
//

import SwiftUI

struct UseLazyHGrid: View {
    // repeating : 固定大小数组
    // count: 列元素个数
    let rows: [GridItem] = Array(repeating: .init(.fixed(100)), count: 2)
    var body: some View {
        VStack(alignment: .center) {
            ScrollView(.horizontal) {
                LazyHGrid(rows: rows) {
                    ForEach(1...10,id:\.self) { _ in
                        Rectangle()
                            .frame(width: 100, height: 100, alignment: .center)
                    }
                }
            }
        }
        
       
    }
}

struct UseLazyHGrid_Previews: PreviewProvider {
    static var previews: some View {
        UseLazyHGrid()
    }
}
